var role = require("../lib/role");
module.exports = {
	prefix: "/user_talk",
	get: {
		"/list_by_friend_id/:friend_id": function() {
			var user = role.getUser(this);
			var friend_id = this.params.friend_id;
			var query = this.request.query;
			var talk_list_info = user.getTalkList(friend_id, query.num, query.page);
			this.body = ResponObj("json", talk_list_info);
		}
	},
	post: {
		"/add_talk/:friend_id": function() {
			var user = role.getUser(this);
			var friend_id = this.params.friend_id;
			var body = this.request.body
			var talk = user.addTalk(friend_id, body.content);
			if (body.back_list) {
				var talk_list_info = user.getTalkList(friend_id, body.num, body.page);
				this.body = ResponObj("json", talk_list_info);
			} else {
				this.body = ResponObj("string", "聊天发送成功");
			}
		}
	}
};